﻿<%@ Page Language="C#" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    

    protected void Page_Load(object sender, EventArgs e)
    {
        //string sql = "Select ISBN,BookName,LastMonthSale,Forecast1,Forecast2,Farecast3 From OrderPrediction4Store where StoreID='01'";
        string sql = "SELECT Sale.SaleID, Sale.CustomerID, Sale.StoreID, Sale.SaleDate, SaleDetail.ISBN, SaleDetail.SellingPrice, SaleDetail.Amount, SaleDetail.Discount FROM Sale INNER JOIN SaleDetail ON Sale.SaleID = SaleDetail.SaleID";
        string DBConfig_sql = @"Data Source=ONEWAY\SQLSERVER;Initial Catalog=BookShop;User ID=sa";
        System.Data.DataSet ds = new System.Data.DataSet();
        System.Data.SqlClient.SqlConnection sqlCon = new System.Data.SqlClient.SqlConnection(DBConfig_sql);
        System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand(sql, sqlCon);
        System.Data.SqlClient.SqlDataAdapter sqlAd = new System.Data.SqlClient.SqlDataAdapter();
        sqlAd.SelectCommand = sqlCmd;
        //sqlAd.Fill(ds, "OrderPrediction4Store");
        sqlAd.Fill(ds, "sale");
        CrystalReportSource1.ReportDocument.Load(Server.MapPath("Reports/SaleReportStore.rpt"));
        //注意此处必需指明Dataset中的表的名称，否则会提示“您请求的报表需要更多信息.”
        CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["sale"]);
        //{?}中的参数可以不用赋值，即使赋了值也不起作用。
        // CrystalReportSource1.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue("1234567");
        
        CrystalReportSource1.ReportDocument.SetDataSource(ds);
        CrystalReportViewer1.ReportSource = CrystalReportSource1;
        CrystalReportViewer1.DataBind();

    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
        rel="stylesheet" type="text/css" />
    <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
        rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
            ReportSourceID="CrystalReportSource1" DisplayGroupTree="False" Height="50px" Width="350px" />
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
        </CR:CrystalReportSource>
    
    </div>
    </form>
</body>
</html>
